﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using ZF.BLL;
using System.Linq.Expressions;
using ZF.BLL;
using System.Linq.Expressions;
using GCELibrary.Current;
using ZF.BLL.Linq;
using GCELibrary.Current;
namespace ZF.WS.expert
{
    public partial class houseList : BLL.Page.PageBase
    {
        public Model.US_Member Expert { get; set; }
        public string EType
        {
            get
            {
                return DictionaryConfig.EExpertType.FirstOrDefault(p => p.Key == Expert.ExpertType).Text;
            }
        }
        [PageArgument(Key = "id", CanNull = false)]
        public int Id { get; set; }

        public static Random Random = new Random();
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var dc = SiteInfo.CreateDBDataContext())
            {
                Expert = dc.US_Member.FirstOrDefault(p => p.MemberId == Id && p.IsExpert);
                
                if (Expert == null)
                {
                    throw WarnFactory.CreateWarn(WarnCode.ReocrdNoFind);
                }
                Expert.E_Article.Load();
                //this.lvArticle.DataSource = Expert.E_Article.Where(p=>p.Type==1).ToList();
                //this.lvArticle.DataBind();
                //this.lvArticle2.DataSource = Expert.E_Article.Where(p => p.Type == 2).ToList();
                //this.lvArticle2.DataBind();
                var list = dc.H_Estate.Where(p => p.IsVerify).Where(p=>p.MemberId==Id)
                   .OrderByDescending(p => p.EstateId).Take(10).ToList();





              var cz=  dc.H_House.Where(p => p.Status == 1 && p.IsVerify).Where(p => p.DealType == 1 || p.DealType == 2)
                  .Where(p => p.MemberId == Id)
                         .OrderByDescending(p => p.HouseId).Take(48).ToList().Select(p =>
                             new
                             {
                                 Address = p.Address,
                                 House = p,
                                 City = SiteInfo.Instance.GetAreaOrDefault(p.AreaId1).Name,
                                 Model = string.Format("{0}房{0}厅", p.HX_Fan, p.HX_Tin),
                                 Price = p.Price,
                                 AddTime = p.AddTime,
                                 Area = DictionaryConfig.HArea.DefaultIfEmpty(a => p.AreaId2.HasValue && a.AreaId == p.AreaId2.Value, new ZF.Model.Dic_Area()).Name,
                             });

              var cs = dc.H_House.Where(p => p.Status == 1 && p.IsVerify).Where(p => p.DealType == 3 || p.DealType == 4)
             .Where(p => p.MemberId == Id)
                    .OrderByDescending(p => p.HouseId).Take(48).ToList().Select(p =>
                        new
                        {
                            Address = p.Address,
                            House = p,
                            City = SiteInfo.Instance.GetAreaOrDefault(p.AreaId1).Name,
                            Model = string.Format("{0}房{0}厅", p.HX_Fan, p.HX_Tin),
                            Price = p.Price,
                            AddTime = p.AddTime,
                            Area = DictionaryConfig.HArea.DefaultIfEmpty(a => p.AreaId2.HasValue && a.AreaId == p.AreaId2.Value, new ZF.Model.Dic_Area()).Name,
                        });





              this.lvJPLP.DataSource = cz;
                this.lvJPLP.DataBind();
                this.lvJPLP1.DataSource = cs;
                this.lvJPLP1.DataBind();
            }

        }
    }
}
